<div class="panel panel-default">

<div class=" panel-heading">Works</div>
<div class="panel-body">
<a class="btn btn-primary btn-sm" href="<?=site_url('catalog/works/addNewWork')?>"><i class="glyphicon glyphicon-plus-sign"></i> <?=nbs(1)?> new work</a>
</div>
<div class="table-responsive" >
	<table class="table table-hover">
		<thead>
			<tr>
				<th>ID</th>
				<th>Name</th>
				<th>Customer</th>
				<th>Description</th>
				<th>Position</th>
				<th>Activity</th>	
				<th>View</th>
				<th>Actions</th>						
			</tr>
		
		</thead>

		<tbody>
		<?php  $last_position = count($works);?>
		<?php foreach ($works as $work) :?>
			
			<tr>
			<form actions="" method="post" role="form" class="form-inline" id="position_up_<?=$work->id?>" enctype="multipart/form-data">
				<input type="hidden" name="work_id" value="<?=$work->id?>">
				<input type="hidden" name="position" value="<?=$work->position?>">
				<input type="hidden" name="action" value="up">
			</form>
			<form actions="" method="post" role="form" class="form-inline" id="position_down_<?=$work->id?>" enctype="multipart/form-data">
				<input type="hidden" name="work_id" value="<?=$work->id?>">
				<input type="hidden" name="position" value="<?=$work->position?>">
				<input type="hidden" name="action" value="down">
			</form>
				<td><?=$work->id?></td>
				<td><?=$work->name?></td>
				<td><?=$work->client_id?></td>
				<td><?=$work->description?></td>
				<td>				
				<button type="button" class="btn btn-primary btn-xs" onclick="position_up(<?=$work->id?>);" <?php if($work->position==1){?>disabled<?php }?>><i class="glyphicon glyphicon-circle-arrow-up"></i></button> 
				<?=$work->position?> 
				<button type="button" class="btn btn-primary btn-xs" onclick="position_down(<?=$work->id?>);" <?php if($last_position == $work->position){?>disabled<?php }?>><i class="glyphicon glyphicon-circle-arrow-down"></i></button>
				</td>		
				<td><?php if($work->active == '1' ){?><span class="label label-success">Active</span><?php }else{?><span class="label label-danger">Blocked</span><?php }?></td>
				<td><a href="<?=site_url('catalog/works/viewWork')?>/<?=$work->id?>" class="btn btn-primary btn-xs"><i class="glyphicon glyphicon-eye-open"></i><?=nbs(2)?>view</a></td>
				<td>
				<div class="btn-group">
				<button type="button" class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown">
				Actions <span class="caret"></span>
				</button>
				<ul class="dropdown-menu" role="menu">
				<li><a href="<?=site_url('catalog/works/edit')?>/<?=$work->id?>" >edit</a></li>
				<li><a href="<?=site_url('catalog/works/deleteWork')?>/<?=$work->id?>" >delete</a></li>
				
				</ul>
			
			</div></td>
			</tr>	
		<?php endforeach;?>
		
		
		</tbody>
	</table>



</div>



</div>